<?php

class Talktangle_Form_Pictangle_Create extends Engine_Form
{
  private $_type = null;
  
      
  public function init()
  {
      $this->setAttrib('id','form_create_pictangle');
      $view = Zend_Registry::get('Zend_View');
      $this->clearDecorators()
//      ->addDecorator('FormElements')
//      ->addDecorator('Form')
      ->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));

        $this->setTitle('Create Pictangle');
        
        $this->addElement('text','title',array(
            'label'=>'Title',
            'description' => $view->translate('This is will show on feed, when you post new tangle.'),
			'required' =>true,
            
            'allowEmtry'=>false,
            'validators' => array (
					array (
						'NotEmpty', 
						true
					)
			)                                             
        ));
         
        $this->addElement('text','description',array(
            'label'=>'Description',
            'description' => $view->translate('This is will show description to user when untanlge.')
			                          
        ));
        
        $core = Engine_Api::_()->talktangle();
        
        if($core->enableTiwtter()){
            $this->addElement('checkbox','post_tiwtter',array(
                'label' => 'send to tiwtter'
            )) ;
        }
        
         if($core->enableFacebook()){
            $this->addElement('checkbox','post_facebook',array(
                'label' => 'send to facebook'
            )) ;
        }
        
      $this->addElement('file', 'main_image', array (
			'label' => 'Main image', 
            'onchange' => 'uploadPics()',
			
		));
      $this->addElement('Cancel','preview_pic',array(
                
                'link' => true, 
    			'href' => ''
                
        
       ));  
       $this->addElement('hidden','imageId',array(
                'order' => 1000
            ));
              
      if ($this->_type == 'company') {
          $this->addElement('select','duration',array(
                'label'=>'Duration',
                'multiOptions' => array(
                    '1' => '1 Day',
                    '2' => '1 Week',
                    '3' => '1 Month',               
                ),                               
            ));
            
          
                  
          
            
           $this->addElement('Cancel','addads',array(
                    'label' => 'Show Ads',
                    'link' => true, 
        			'href' => '',
                    'onclick' => 'ShowAds(this)'
            
                )
            );
             
                 
        
            $this->addElement('Text','ads_description',array(
                'label'=>'Ads Description',
    			'onkeyup' =>'keyUpAdsDescription(this)',
                
                
            ));
            
            $this->addElement('file', 'image_upload', array (
    			'label' => 'Ads image', 
                'onchange' => 'uploadAds()',
    			
    		));
            
            $this->addElement('Cancel','preview_ads',array(
                    
                    'link' => true, 
        			'href' => ''
                    
            
                )
            );  
            $this->addElement('hidden','adsId',array(
                'order' => 1001
            ));
            
            
    
            
                 
        
            $this->addElement('Text','promotion_description',array(
                'label'=>'Promotion Description'
                
                
            ));
            $this->addElement('file', 'promotion_image', array (
    			'label' => 'Promotion image', 
                'onchange' => 'uploadPromotion()',
    			
    		));
            
            $this->addElement('Cancel','preview_promotion',array(
                    
                    'link' => true, 
        			'href' => ''
                    
            
                )
            );  
            $this->addElement('hidden','promotion_id',array(
                'order' => 1002
            ));
       	
        }
        
       $this->addElement('Button', 'submit', array (
			'label' => 'Submit', 
			'type' => 'submit',
            'onclick' => 'return checkValidSubmitForm();',
			'decorators' => array (
				'ViewHelper'
			)
		)); 
       
		$this->addElement('Cancel', 'cancel', array (
				'label' => 'cancel', 
				'link' => true, 
				'href' => '', 
                'onclick' => 'cancelCreate();',
				'decorators' => array (
						'ViewHelper'
				)
		));               

        $this->addDisplayGroup(array('submit', 'cancel'), 'buttons', array(
          'decorators' => array(
            'FormElements',
            'DivDivDivWrapper',
          ),
        ));           
  }
  
  public function setType($type){
    $this->_type = $type;
  }
  public function getType(){
    return $this->_type;
  }
  
  public function isUploadAdvertise(){
     return true;
  }
}  